/*
 * isTypes.h
 *
 *  Created on: Jun 6, 2012
 *      Author: marchi
 */

#ifndef ISTYPES_H_
#define ISTYPES_H_
#include "CavityData.h"
#include <algorithm>
#include <functional>
using std::bind1st;
using std::equal_to;

namespace Cavities {

class isTypes {
protected:
	bool xnot;
	virtual bool isSomething(int x, unsigned int y)const=0;
public:
	isTypes():xnot(true){};
	isTypes(bool x):xnot(x){};
	bool operator()(const std::pair<const Vertex,CavityData> & y) const {
		const Vertex tm1=y.second.gVtx();
		vector<int> tm0=tm1.gnoVertex();
		int n=count_if(tm0.begin(),tm0.end(),bind1st(equal_to<int>(),0));
		return isSomething(n,tm0.size());
	}
	bool operator()(const Vertex & y) const {
		const Vertex tm1=y;
		vector<int> tm0=tm1.gnoVertex();
		int n=count_if(tm0.begin(),tm0.end(),bind1st(equal_to<int>(),0));
		return isSomething(n,tm0.size());
	}
	virtual ~isTypes(){};
};
class isSurface: public isTypes{
	virtual bool isSomething(int x, unsigned int y)const {
		if(x == 0 || x == static_cast<int> (y)) return !xnot;
		return xnot;
	}
public:
	virtual ~isSurface(){};
};
class isSurfProtein: public isTypes{
	virtual bool isSomething(int x, unsigned int y)const {
		if(x == static_cast<int> (y)) return !xnot;
		return xnot;
	}
public:
	virtual ~isSurfProtein(){};
};
class isWater: public isTypes {
	virtual bool isSomething(int x, unsigned int y)const {
		if(x != static_cast<int> (y)) return !xnot;
		return xnot;
	}
public:
	virtual ~isWater(){};
};
class isProtein: public isTypes {
	virtual bool isSomething(int x, unsigned int y)const {
		if(x != 0) return !xnot;
		return xnot;
	}
public:
	virtual ~isProtein(){};
};

} /* namespace Cavities */
#endif /* ISTYPES_H_ */
